using System;
using System.Globalization;
using System.Windows.Data;
using System.Windows.Markup;
using System.Windows.Media;
using TciNewsReader_2014_04.Model;
namespace TciNewsReader_2014_04.Converters
{
    public class ItemStatusToColourConverter : MarkupExtension, IValueConverter
    {
        public ItemStatusToColourConverter(){}
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            try
            {
                var status = (ItemStatus) value;
                switch (status)
                {
                    case ItemStatus.NotRead:
                        return Brushes.PapayaWhip;
                    case ItemStatus.Read:
                        return Brushes.LightGray;
                    case ItemStatus.Current:
                        return Brushes.Yellow;
                    default:
                        return Brushes.BlanchedAlmond;
                }
            }
            catch (Exception)
            {
                return Brushes.Red;
            }
        }
        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            return null;
        }
        public override object ProvideValue(IServiceProvider serviceProvider)
        {
            return this;
        }
    }
}